package cqrtplm.controller;

import cqrtplm.constant.RouteConstant;
import cqrtplm.entity.RatoCpytDO;
import cqrtplm.entity.RtPrimaryPurpose;
import cqrtplm.service.RatoCpytService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(RouteConstant.CPYT)
//    public static final String CPYT = "rest/cpyt/";
@RequiredArgsConstructor
public class RatoCpytController {
    private final RatoCpytService ratoCpytService;

    @PostMapping
    public int create(@RequestBody RatoCpytDO record) {
        return ratoCpytService.create(record);
    }

    @DeleteMapping("/{id}")
    public int delete(@PathVariable String id) {
        return ratoCpytService.delete(id.toString());
    }

    @PutMapping
    public int update(@RequestBody RatoCpytDO record) {
        return ratoCpytService.update(record);
    }

    @GetMapping("/{id}")
    public RatoCpytDO getById(@PathVariable String id) {
        return ratoCpytService.getById(id.toString());
    }
    @GetMapping("/enum")
    public List<RtPrimaryPurpose> getById() {
        return ratoCpytService.getEnum();
    }

    @GetMapping
    public List<RatoCpytDO> query(RatoCpytDO condition) {
        return ratoCpytService.query(condition);
    }
}
